package com.amrit;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistryBuilder;

public class HibernateMain {

	public static void main(String[] args) {

		Shape shape = new Shape("Sqaure");
		Rectangle rectangle = new Rectangle("Rectangle", 10, 20);
		Circle circle = new Circle("Circle", 4);

		Configuration configuration = new Configuration();
		configuration.configure();
		org.hibernate.service.ServiceRegistry sr = new ServiceRegistryBuilder()
				.applySettings(configuration.getProperties()).build();
		SessionFactory sf = configuration.buildSessionFactory(sr);
		Session ss = sf.openSession();

		ss.beginTransaction();
		ss.save(shape);
		ss.save(rectangle);
		ss.save(circle);
		ss.getTransaction().commit();
		ss.close();

	}
}